home *** CD-ROM | disk | FTP | other *** search
- 5 poke53281,0:poke53280,0:print"[147][159]"chr$(142)
- 10 rem initialize
- 15 a=1:b=1:c=1:d=1:e=1:f=1:g=1:h=1:i=1:j=1:k=1:l=1:ls=0:rs=0:ct=0:dimp(8)
- 20 print"[147]enter odd unit (a-l): ";:inputa$
- 25 ifa$<"a"ora$>"l"then20
- 30 print"enter (l)ight or (h)eavy: ";:inputw$
- 35 ifw$<>"l"andw$<>"h"then30
- 40 print"[147]";:w=2:ifw$="l"thenw=0
- 45 onasc(a$)-64goto51,52,53,54,55,56,57,58,59,60,61,62
- 46 stop
- 51 a=w:goto65
- 52 b=w:goto65
- 53 c=w:goto65
- 54 d=w:goto65
- 55 e=w:goto65
- 56 f=w:goto65
- 57 g=w:goto65
- 58 h=w:goto65
- 59 i=w:goto65
- 60 j=w:goto65
- 61 k=w:goto65
- 62 l=w
- 65 goto200:rem jump to start
- 100 rem weighing subroutine
- 105 ls=0:rs=0:forz=1to4:ls=ls+p(z):rs=rs+p(z+4):p(z)=0:p(z+4)=0:next
- 110 bal=0:rem in balance
- 115 ifls<rsthenbal=1:rem left side is up
- 120 ifls>rsthenbal=-1:rem left side is down
- 125 ct=ct+1:print"weighing #";ct;" ";x$
- 130 ifbal=othenprint"balanced"
- 135 ifbal=1thenprint"left side up"
- 140 ifbal=-1thenprint"left side down"
- 145 print"";:return
- 200 p(1)=a:p(2)=b:p(3)=c:p(4)=d
- 205 p(5)=e:p(6)=f:p(7)=g:p(8)=h
- 210 x$="abcd efgh"
- 215 gosub100:b1=bal
- 220 ifbal<>0then400
- 225 p(1)=a:p(2)=b:p(3)=c:p(5)=i:p(6)=j:p(7)=k:x$="abc- ijk-"
- 230 gosub100:b2=bal
- 235 ifbal<>0then300
- 240 p(1)=a:p(5)=l:x$="a--- l---"
- 245 gosub100:b3=bal
- 250 ifb3=-1thenprint"l is light"
- 255 ifb3=1thenprint"l is heavy"
- 260 goto1000:rem end
- 300 p(1)=i:p(5)=j:x$="i--- j---"
- 305 gosub100:b3=bal
- 310 ifb3=0andb2=1thenprint"k is heavy"
- 315 ifb3=0andb2=-1thenprint"k is light"
- 320 ifb2=-1andb3=1thenprint"i is light"
- 325 ifb2=1andb3=-1thenprint"i is heavy"
- 330 ifb2=-1andb3=-1thenprint"j is light"
- 335 ifb2=1andb3=1thenprint"j is heavy"
- 340 goto1000:rem end
- 400 p(1)=d:p(2)=e:p(3)=f:p(5)=g:p(6)=h:p(7)=i:x$="def- ghi-"
- 405 gosub100:b2=bal
- 410 ifb2<>0then500
- 415 p(1)=a:p(5)=b:x$="a--- b---"
- 420 gosub100:b3=bal
- 425 ifb3=0andb1=1thenprint"c is light"
- 430 ifb3=0andb1=-1thenprint"c is heavy"
- 435 ifb3=1andb1=1thenprint"a is light"
- 440 ifb3=1andb1=-1thenprint"b is heavy"
- 445 ifb3=-1andb1=1thenprint"b is light"
- 450 ifb3=-1andb1=-1thenprint"a is heavy"
- 455 goto1000:rem end
- 500 ifb1=b2then600
- 505 p(1)=e:p(5)=f:x$="e--- f---"
- 510 gosub100:b3=bal
- 515 ifb3=1andb2=1andb1=-1thenprint"e is light"
- 520 ifb3=-1andb2=-1andb1=1thenprint"e is heavy"
- 525 ifb3=1andb2=-1andb1=1thenprint"f is heavy"
- 530 ifb3=-1andb2=1andb1=-1thenprint"f is light"
- 535 goto1000:rem end
- 600 p(1)=g:p(5)=h:x$="g--- h---"
- 605 gosub100:b3=bal
- 610 ifb3=0andb2=1thenprint"d is light"
- 615 ifb3=0andb2=-1thenprint"d is heavy"
- 620 ifb3=1andb2=1thenprint"h is heavy"
- 625 ifb3=1andb2=-1thenprint"g is light"
- 630 ifb3=-1andb2=1thenprint"g is heavy"
- 635 ifb3=-1andb2=-1thenprint"h is light"
- 640 goto1000:rem end
- 1000 print"again? (y/n)"
- 1005 geta$:ifa$="y"thenrun
- 1010 ifa$<>"n"then1005
- 1015 end
- 10000 open15,8,15,"s0:scale simulator":close15:save"scale simulator",8:end
-